﻿using Microsoft.EntityFrameworkCore;
using MySystemSetup.BusinessDomain;
using MySystemSetup.RBACDomain;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;

namespace MySystemSetup.EntityFrameworkCore;

public static class MySystemSetupDbContextModelCreatingExtensions
{
    public static void ConfigureMySystemSetup(
        this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));

        /* Configure all entities here. Example:

        builder.Entity<Question>(b =>
        {
            //Configure table & schema name
            b.ToTable(MySystemSetupDbProperties.DbTablePrefix + "Questions", MySystemSetupDbProperties.DbSchema);

            b.ConfigureByConvention();

            //Properties
            b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);

            //Relations
            b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);

            //Indexes
            b.HasIndex(q => q.CreationTime);
        });
        */


        builder.Entity<Permission>(b =>
        {
            //Configure table & schema name
            b.ToTable("Permission");

            b.ConfigureByConvention();


        });

        builder.Entity<RoleInfo>(b =>
        {
            //Configure table & schema name
            b.ToTable("RoleInfo");

            b.ConfigureByConvention();


        });

        builder.Entity<RolePermission>(b =>
        {
            //Configure table & schema name
            b.ToTable("RolePermission");

            b.ConfigureByConvention();


        });
        builder.Entity<UserInfo>(b =>
        {
            //Configure table & schema name
            b.ToTable("UserInfo");

            b.ConfigureByConvention();


        });
        builder.Entity<UserRole>(b =>
        {
            //Configure table & schema name
            b.ToTable("UserRole");

            b.ConfigureByConvention();


        });
        builder.Entity<SheepYard>(b =>
        {
            //Configure table & schema name
            b.ToTable("SheepYard");

            b.ConfigureByConvention();


        });

        builder.Entity<GiveInfo>(b =>
        {
            //Configure table & schema name
            b.ToTable("GiveInfo");

            b.ConfigureByConvention();


        });

        builder.Entity<FieldInfo>(b =>
        {
            //Configure table & schema name
            b.ToTable("FieldInfo");

            b.ConfigureByConvention();


        });

        builder.Entity<Entrepreneur>(b =>
        {
            //Configure table & schema name
            b.ToTable("Entrepreneur");

            b.ConfigureByConvention();


        });

    }
}
